package simbot.example.demo.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.stereotype.Component;

import java.io.IOException;


/**
 * @author kali
 * @email kalilinux@vip.qq.com
 * @date 2020/6/9
 */
@Component
public class NumberSerializerUtils  extends JsonSerializer<Integer> {

    @Override
    public void serialize(Integer status, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        String statusStr = "";
        switch (status) {
            case 0:
                statusStr = "暂存";
                break;
            case 1:
                statusStr = "待上报";
                break;
            case 2:
                statusStr = "待审核";
                break;
            case 3:
                statusStr = "已审";
                break;
            case 4:
                statusStr = "退回";
                break;
            case -1:
                statusStr = "已删";
                break;
            default:
                statusStr = "状态信息不符合";
        }
        jsonGenerator.writeString(statusStr);
    }

}
